<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<div class="modal-dialog ms-modal-dialog" style="width: 800px;">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">编辑</h4>
    </div>
	  
	  <form method="POST" action="${ctx.host}/trailers/${trailer.id}/edit-info" class="form-horizontal ms-form modal-search-form" data-validate="true">
	    
	    <input type="hidden" name="_method" value="PATCH"/>
	    <input type="hidden" name="id" value="${trailer.id}"/>
	    
	    <div class="modal-body">
      
        <c:choose>
          <c:when test="${trailer.status.qualified}">
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">1&nbsp;<span class="color-red">*</span>实际长*宽*高：</label>
              <div class="col-xs-6 pull-left">
                <input type="text" name="length" value="${trailer.length}"  data-validate="required|max_decimal_digit,2" class="form-control" style="display: inline-block; width: 28%;" placeholder="长" tabindex="11" autocomplete="off" /><span>*</span> 
                <input type="text" name="width" value="${trailer.width}" data-validate="required|max_decimal_digit,2" class="form-control" style="display: inline-block; width: 28%;" placeholder="宽" tabindex="11" autocomplete="off" /><span>*</span> 
                <input type="text" name="height" value="${trailer.height}" data-validate="required|max_decimal_digit,2" class="form-control" style="display: inline-block; width: 28%;" placeholder="高" tabindex="11" autocomplete="off" />
              </div>
            </div>
          </c:when>
          
          <c:otherwise>
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">1&nbsp;<span class="color-red">*</span>产证所有者：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="floorLord" value="${trailer.floorLord}" data-validate="required" class="form-control" placeholder="产证所有者" tabindex="9" autocomplete="off" />
              </div>
    
              <label class="control-label col-xs-2">2&nbsp;<span class="color-red">*</span>挂车类型：</label>
              <div class="col-xs-3 pull-left">
                <select name="trailerType" data-validate="required" class="select2 form-control" tabindex="6">
                  <option></option>
                  <c:forEach var="trailerType" items="${enums['TrailerType']}">
                    <option value="${trailerType}" ${trailerType eq trailer.trailerType ? 'selected' : ''}>${trailerType.description}</option>
                  </c:forEach>
                </select>
              </div>
            </div>
    
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">3&nbsp;<span class="color-red">*</span>中文车牌号：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="brandCNCode" value="${trailer.brandCNCode}" data-validate="required|brand_cn_code" class="form-control" placeholder="例：沪DS6057" tabindex="9" autocomplete="off" />
              </div>
    
              <label class="control-label col-xs-2">4&nbsp;<span class="color-red">*</span>VIN码：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="vincode" value="${trailer.vincode}" data-validate="required" class="form-control" placeholder="VIN码" tabindex="10" autocomplete="off" />
              </div>
            </div>
    
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">5&nbsp;<span class="color-red">*</span>实际长*宽*高：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="length" value="${trailer.length}"  data-validate="required|max_decimal_digit,2" class="form-control" style="display: inline-block; width: 28%;" placeholder="长" tabindex="11" autocomplete="off" /><span>*</span> 
                <input type="text" name="width" value="${trailer.width}" data-validate="required|max_decimal_digit,2" class="form-control" style="display: inline-block; width: 28%;" placeholder="宽" tabindex="11" autocomplete="off" /><span>*</span> 
                <input type="text" name="height" value="${trailer.height}" data-validate="required|max_decimal_digit,2" class="form-control" style="display: inline-block; width: 28%;" placeholder="高" tabindex="11" autocomplete="off" />
              </div>
    
              <label class="control-label col-xs-2">6&nbsp;<span class="color-red">*</span>装载量：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="trainload" value="${trailer.trainload}" data-validate="required|number" class="form-control" placeholder="装载量" tabindex="16" autocomplete="off" />
              </div>
            </div>
    
            <div class="form-group ms-form-group">
              <label class="control-label col-xs-3">7&nbsp;<span class="color-red">*</span>年检有效期至：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="annualInspectionDate" value="<fmt:formatDate value="${trailer.annualInspectionDate}" pattern="yyyy-MM"/>" data-validate="required" class="form-control month" placeholder="年检有效期至" tabindex="16" autocomplete="off" />
              </div>
              
              <label class="control-label col-xs-2">8&nbsp;<span class="color-red">*</span>轴数：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="axles" value="${trailer.axles}" data-validate="required|number" class="form-control" placeholder="轴数" tabindex="16" autocomplete="off" />
              </div>
            </div>
            
            <div class="form-group  ms-form-group">
              <label class="control-label col-xs-3">9&nbsp;<span class="color-red">*</span>车辆类型（行驶证）：</label>
              <div class="col-xs-3 pull-left">
                <select name="vehicleType" data-validate="required" class="select2 form-control" tabindex="6">
                  <option></option>
                  <c:forEach var="vehicleType" items="${enums['TrailerVehicleType']}">
                    <option value="${vehicleType}" ${vehicleType eq trailer.vehicleType ? 'selected' : ''}>${vehicleType.description}</option>
                  </c:forEach>
                </select>
              </div>
              
              <label class="control-label col-xs-2">10&nbsp;<span class="color-red">*</span>品牌：</label>
              <div class="col-xs-3 pull-left">
                <input type="text" name="brand" value="${trailer.brand}" data-validate="required" class="form-control" placeholder="品牌" tabindex="16" autocomplete="off" />
              </div>
            </div>
          </c:otherwise>
        </c:choose>
      
	    </div>
	  
	    <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary btn-submit">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>
	    
	  </form>
	  
  </div>
</div>

<script>
  $(document).ready(function(){

    $('select[name="trailerType"]').select2({
      placeholder: '请选择',
      minimumResultsForSearch: -1,
      allowClear: true,
    });
    
    $('select[name="vehicleType"]').select2({
      placeholder: '请选择',
      minimumResultsForSearch: -1,
      allowClear: true,
    });

    $('.month').datetimepicker({  
      format: 'yyyy-mm',
      autoclose: true,
      startView: 'year',  
      minView: 'year',  
      language: 'zh-CN'  
    }); 
    
  });
</script>